<?php
	$idMat=$_GET["id"];
	include "header.html";
?>

<head>
  <meta charset="utf-8" />
  <title>jQuery UI Accordion - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <style>
  .tablaDetalle{
  	border: 1px solid black;
  	cellpadding: 0px;
  	cellspacing: 0px;
  }
  .tablaDetalle td, th {
  	border: 1px solid black;
  	cellpadding: 0px;
  	cellspacing: 0px;
  	text-align: center;
  	width: 80px;
  }
  </style>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <script type="text/javascript" src="framework/js/util.js"></script>
	<script type="text/javascript" src="framework/js/DB.js"></script>
  <script>  
  var maquinas;
  var estados;
  var tipos;

  $(document).ready(function(){
  	jQuery.ajaxSetup({async:false});
  	maquinas=makeCombo("elementoDiv","maquina","maquina","descripcion","");
  	estados=makeCombo("containerEstado","item_estado","matriceria_item_estado","descripcion","");
  	tipos=makeCombo("containerTipo","item_tipo","matriceria_item_tipo","descripcion","generaNumeroItem");
  	tipoItems= DBHloadMap("matriceria_item_tipo", {}, "matriz");
  	armaVista(<?php echo $idMat;?>);
	$( "#vistaA" ).accordion();
	$( "#vistaM" ).accordion();
	$( "#tabs" ).tabs();
  });

  function armaVista(id){
	 	var x;
		var strM="";
		var strA="";
		var params={};
		params["idMatriceria"]=id;
		items=DBHload("matriceria_item",params,"idTipo");
		
		
		for (x=0;x<items.rowCount;x++){
			var obj=items.rows[x];		
			str="";
			str += "<h3>" +  tipos[obj.idTipo] + " (" +  obj.codigo + ") | <span style='text-indent: 5em'>" + estados[obj.idEstado] + " </span> " +  "</h3>";
			if (obj.planoURL!=""){
				str+="<div><p><span style='display:block'><a href=\"file://///" + obj.planoURL + "\" target='_blank'>Ver Plano .. </a></span>";
			}else{
				str+="<div><p><span style='display:block;color: red;font-weight:bold;'>Item sin Plano Adjunto !!</span>";
			}
			var params={};
			params["idItem"]=obj.id;
			cotas=DBHload("matriceria_item_cota",params,"nombre");
			str += "<table class='tablaDetalle'><thead><th>Cota</th><th>Minimo</th><th>Maximo</th></thead>";
			for (i=0;i<cotas.rowCount;i++){
				
				var cota=cotas.rows[i];
				str+= "<TR><TD>" + cota.nombre + "</TD><TD>" + cota.minimo + "</TD><TD>" + cota.maximo + "</TD></TR>";
			}
			str+="</table></p></div>";
			if (tipoItems[obj.idTipo]==1){
				strM+=str;
			}else{
				strA+=str;
			}
		}
		$("#vistaA").html(strA);			
		$("#vistaM").html(strM);
	}
  
  </script>
</head>
<?php 
	include "menuMatriceria.html";
?>
<div class="container_12">
 <div class="grid_10">
 <div id="tabs">
  <ul>
    <li><a href="#vistaM">Matrices</a></li>
    <li><a href="#vistaA">Auxiliares</a></li>    
  </ul>
	<div id="vistaM">
  
	</div>
	<div id="vistaA">
  
	</div>
	</div>
</div></div>

    <?php include "footer.html"?>